package com.wuzihao.disk.file.service.impl;

import com.wuzihao.disk.file.entity.SearchFileEntity;
import com.wuzihao.disk.file.repository.FileDao;
import com.wuzihao.disk.file.service.FileService;
import com.wuzihao.disk.mybatis.entity.PtFileEntity;
import com.wuzihao.disk.mybatis.entity.PtUserEntity;
import com.wuzihao.disk.mybatis.flexigrid.PagingEntity;
import com.wuzihao.disk.mybatis.flexigrid.TblResponseEntity;
import com.wuzihao.disk.user.entity.SearchUserEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class FileServiceImpl implements FileService {

    @Resource
    private FileDao fileDao;

    //查询文件列表
    @Override
    public List<PtFileEntity> queryFileList() {
        return fileDao.queryFileList();
    }

    //分页查询
    @Override
    public TblResponseEntity<PtFileEntity> queryFileInfoListByPage(SearchFileEntity entity, PagingEntity paging) {

        TblResponseEntity<PtFileEntity> responseEntity = new TblResponseEntity<>();
        Integer total = fileDao.queryFileTotal(entity);
        responseEntity.setTotal(total);
        paging.deal(PtFileEntity.class, total);


        responseEntity.setPage(paging.getPage());
        List<PtFileEntity> rawRecords = fileDao.queryFileInfoListByPage(entity, paging);
        responseEntity.setRawRecords(rawRecords);


        responseEntity.deal();
        return responseEntity;
    }

    @Override
    public boolean uploadFiles(MultipartFile[] files, String targetDir) {
        return false;
    }


    @Override
    public void saveFileInfo(List<PtFileEntity> ptFileEntityList) {
        fileDao.deleteFileAll();
        fileDao.saveFileInfo(ptFileEntityList);


    }

    @Override
    public PtFileEntity queryFileInfoById(String fileUuid) {
        return fileDao.queryFileInfoById(fileUuid);
    }

    @Override
    public List<Map<String, Object>> queryDirectoryTree() {
        return null;
    }

    @Override
    public void copyFile(String fileUuid, String targetDir) {

    }

    @Override
    public String queryFileNameByUuid(String fileUuid) {
        return null;
    }

    @Override
    public void modifyFileInfoById(PtFileEntity entity) {
        fileDao.modifyFileInfoById(entity);
    }


}
